~:extend('_index')~

~:block('body')~
	<div class="page-header">
		<h1>
			<small>~~:escape($class.namespace)~\</small> ~~:escape($class.name)~
			~if ($class.parent !== null):~
				<small>(extends ~~:escape($class.parent)~)</small>
			~endif~
		</h1>
	</div>

	<p class="lead">
		~~:escape($class.doc.content.0)~
	</p>
		
	~if (isset($class.doc.content.1)):~
		~~:markdown(:raw($class.doc.content.1))~
	~endif~
	
	/* Only show members if there are public ones */
	<?php
	$show_members = false;
	foreach ($class.members as $member) {
		if (:raw($member['visibility']) == 'public' || :raw($show_protected_and_private)) $show_members = true;
	}
	?>

	~if ($show_members):~
		<h2>Members</h2>

		<table class="table table-striped table-condensed" id="table_members">
		<colgroup>
			<col width="1">
			<col width="1">
			<col width="1">
			<col width="*">
		</colgroup>
		<tbody>

			~foreach ($class.members as $member):~
				~if (isset($member.tags.hidden) && !:raw($show_protected_and_private)) continue;~
				~if (:raw($member.visibility) !== 'public' && !:raw($show_protected_and_private)) continue;~
				<tr>
					<td>
						~:render('elements/visibility', array('visibility' => :raw($member.visibility)))~
						~if (isset($member.tags.hidden)):~
							<small><span class="label label-default">Hidden</span></small>
						~endif~
					</td>
					<td><span class="type">~~:escape($member.tags.var.0.type)~</span></td>
					<td>
						<code>
							$~~:escape($member.name)~
							<?php
							if ($member.default) {
								:render('elements/optional', array('default' => :raw($member.default)));
							}
							?>
						</code>
					</td>
					<td>~~:markdown(:raw($member.content.title))~</td>
				</tr>
			~endforeach~
		</tbody>
		</table>
	~endif~

	/* Only show functions if there are public ones */
	<?php
	$public_methods_available = false;
	foreach ($class.methods as $method) {
		if (:raw($method['visibility']) == 'public' || :raw($show_protected_and_private)) $show_methods = true;
	}
	?>

	~if ($show_methods):~
		<h2>Functions</h2>

		~foreach ($class.methods as $key => $method):~
			~if ($method === false):~
				<p>
					DocComment for method <code>~~$key~()</code> is missing.
				</p>
			~endif~

			~if (isset($method.tags.hidden) && !:raw($show_protected_and_private)) continue;~
			~if (:raw($method.visibility) !== 'public' && !:raw($show_protected_and_private)) continue;~
			<div class="function-wrapper">
				<h4>
					~:render('elements/visibility', array('visibility' => :raw($method.visibility)))~
					
					~if (isset($method.tags.hidden)):~
						<small><span class="label label-default">Hidden</span></small>
					~endif~

					~~:escape($method.name)~(
					
					<code>
						~foreach ($method.parameters as $p):~
							<?php
							:render('elements/type', array('type' => :raw($p.type))) . ' ';

							if ($p.passedByReference) echo '&';
							echo '$'.:escape($p.name);

							if ($p.optional) {
								:render('elements/optional', array('default' => :raw($p.default)));
							}

							if ($p !== end($method.parameters)) {
								echo ','; 
							}
							?>
						~endforeach~
					</code>)
				</h4>
				
				~~:markdown(:raw($method.content.title))~

				<div class="well">
					~if (isset($method.content.description)):~
						~~:markdown(:raw($method.content.description))~
					~endif~

					~if (count($method.parameters) !== 0):~
						<h5>Parameters</h5>
					
						<table class="table table-condensed">
						<colgroup>
							<col width="1">
							<col width="1">
							<col width="*">
						</colgroup>
						<tbody>
							~foreach ($method.parameters as $p):~
								<tr>
									<td>~:render('elements/type', array('type' => :raw($p.type)))~</td>
									<td><code>$~~:escape($p.name)~</code></td>
									<td>~~:markdown(:raw($p.description))~</td>
								</tr>
							~endforeach~
						</tbody>
						</table>
					~endif~


					~if (isset($method.tags.return)):~
						<h5>Returns</h5>

						<table class="table table-condensed">
						<colgroup>
							<col width="1">
							<col width="*">
						</colgroup>
						<tbody>
							<tr>
								<td>~:render('elements/type', array('type' => :raw($method.tags.return.0.type)))~</td>
								<td>
									~if (isset($method.tags.return.0.description)):~
										~~:markdown(:raw($method.tags.return.0.description))~
									~endif~
								</td>
							</tr>
						</tbody>
						</table>
					~endif~
				</div>
			</div>
		~endforeach~
	~endif~

~:endblock()~
